package com.ruoyi.locate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.locate.domain.WWarehouseMapDataExt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.locate.domain.WWarehouseMapData;
import com.ruoyi.locate.service.IWWarehouseMapDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓位数据Controller
 * 
 * @author ruoyi
 * @date 2025-01-08 17:39:15
 */
@RestController
@RequestMapping("/locates/data")
public class WWarehouseMapDataController extends BaseController
{
    @Autowired
    private IWWarehouseMapDataService wWarehouseMapDataService;

    private static Logger logger = LoggerFactory.getLogger(WWarehouseMapDataController.class);
    /**
     * 查询仓位数据列表
     */
    @PreAuthorize("@ss.hasPermi('locates:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(WWarehouseMapData wWarehouseMapData)
    {
        startPage();
        List<WWarehouseMapData> list = wWarehouseMapDataService.selectWWarehouseMapDataList(wWarehouseMapData);
        return getDataTable(list);
    }

    /**
     * 导出仓位数据列表
     */
    @PreAuthorize("@ss.hasPermi('locates:data:export')")
    @Log(title = "仓位数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WWarehouseMapData wWarehouseMapData)
    {
        List<WWarehouseMapData> list = wWarehouseMapDataService.selectWWarehouseMapDataList(wWarehouseMapData);
        ExcelUtil<WWarehouseMapData> util = new ExcelUtil<WWarehouseMapData>(WWarehouseMapData.class);
        util.exportExcel(response, list, "仓位数据数据");
    }

    /**
     * 获取仓位数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('locates:data:query')")
    @GetMapping(value = "/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return success(wWarehouseMapDataService.selectWWarehouseMapDataByDataId(dataId));
    }

    /**
     * 新增仓位数据
     */
    @PreAuthorize("@ss.hasPermi('locates:data:add')")
    @Log(title = "仓位数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WWarehouseMapData wWarehouseMapData)
    {
        wWarehouseMapData.setCreateBy(getNickName());
        return toAjax(wWarehouseMapDataService.insertWWarehouseMapData(wWarehouseMapData));
    }

    /**
     * 修改仓位数据
     */
    @PreAuthorize("@ss.hasPermi('locates:data:edit')")
    @Log(title = "仓位数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WWarehouseMapData wWarehouseMapData)
    {
        wWarehouseMapData.setUpdateBy(getNickName());
        return toAjax(wWarehouseMapDataService.updateWWarehouseMapData(wWarehouseMapData));
    }

    /**
     * 删除仓位数据
     */
    @PreAuthorize("@ss.hasPermi('locates:data:remove')")
    @Log(title = "仓位数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(wWarehouseMapDataService.deleteWWarehouseMapDataByDataIds(dataIds));
    }

    /**
     * 查询仓位数据列表
     */
    //@PreAuthorize("@ss.hasPermi('locates:data:list')")
    @GetMapping("/dataext")
    public AjaxResult getMapDataExt(WWarehouseMapDataExt wWarehouseMapDataExt)
    {
//        logger.debug("ZZZ, getMapData = " + wWarehouseMapDataExt);
        return success(wWarehouseMapDataService.selectWWarehouseMapDataExt(wWarehouseMapDataExt));
    }
}
